import { defineStore } from "pinia";
import { StoreID, GlobalConfig } from "@/config";
import { persistedStateConfig } from "@/config";

export const useKeepAliveStore = defineStore(StoreID.KEEP_ALIVE_STORE, {
    state: (): KeepAliveState => ({
        keepAliveName: [],
    }),

    getters: {},

    actions: {
        // Add KeepAliveName
        async addKeepAliveName(name: string) {
            !this.keepAliveName.includes(name) && this.keepAliveName.push(name);
        },
        // Remove KeepAliveName
        async removeKeepAliveName(name: string) {
            this.keepAliveName = this.keepAliveName.filter((item) => item !== name);
        },
        // Set KeepAliveName
        async setKeepAliveName(keepAliveName: string[] = []) {
            this.keepAliveName = keepAliveName;
        },
    },

    persist: true
});
